Repository navigation
test(web): wait for Settings focus before testing the theme editor's Escape - #36754
Merged
Merged
Conversation
…Escape Settings' modal dialog moves focus to its first control on a later animation frame. When that frame landed after the test focused the theme editor's input, focus went back to Settings and Escape never reached the editor. Wait for Settings to hold focus first, as it does in the app before the editor opens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — The changes are confined to an ignored file and are described as stabilizing focus timing in a theme-editor test. The supplied scope indicates no material change to production behavior. Notes:
You can add or adjust custom eligibility rules. Learn more. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Flaky test. ThemeEditorPanel.browser.test.tsx > 'closes on Escape without closing Settings' renders a modal Settings Dialog and the ThemeEditorPanel together. Base UI's FloatingFocusManager moves the dialog's initial focus in a requestAnimationFrame (enqueueFocus). When that frame lands after the test focuses the editor input (as can happen on a loaded CI runner), focus is pulled back into Settings and Escape never reaches the editor's onKeyDown, so onEditorOpenChange gets 0 calls (the CI failure). Reproduced deterministically by delaying requestAnimationFrame by 150ms in a scratch copy: identical failure; with the fix the same delayed copy passes. Not a product bug: in the app Settings is already open and focused before the editor opens. Fix: renderBesideSettings now waits until Settings' Close button has focus (expect.element(...).toHaveFocus()) before returning, which matches that real order. It also holds the screen in an AsyncDisposableStack so a failed wait still unmounts, as AGENTS.md asks. Test-only change, no retry, sleep or timeout.
Reproduction on main
Run the failing check on main.
Evidence
The checks on this pull request are the proof: it changes what main's checks run, not what the app does.
Tests
Before fix:
vp test run --project browser src/components/settings/ThemeEditorPanel.browser.test.tsx10/10 pass on origin/main (flake not reproduced naturally). Scratch repro with requestAnimationFrame delayed 150ms: fails with 'Number of calls: 0'; with the fix: 5/5 tests pass. After fix: the full file passed 25 consecutive times, before and again after the AsyncDisposableStack refactor (25/25 each).vp run check:changed: format, lint, knip, typecheck (2 packages), test all pass.Not in this change
Who did the work
Run by the t3code factory in T3 Code.